/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package action.activity;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import myUtils.page.Result;
import org.apache.struts2.interceptor.ServletRequestAware;
import po.Activity;
import po.User;
import service.ActivityService;
/**
 *
 * @author HX
 */
public class GetOrgActivitiesAction extends ActionSupport implements ServletRequestAware
{
    private ActivityService activityService;
    private HttpServletRequest request;
    private List<Activity> futureActivities;
    private List<Activity> hisoryActivities;
    private int userId;
    

     @Override
    public String execute()
     {
         int orgId;
         String msg;
         if (ActionContext.getContext().getSession().get("user") == null) {
            msg = "you should login first";
            request.setAttribute("msg", msg);
            return ERROR;
         }
         else {
            userId = ((User) ActionContext.getContext().getSession().get("user")).getId();
            if(request.getParameter("orgId")==null)
            {
                msg="no id!!!";
                request.setAttribute("msg", msg);
                return ERROR;
            }
            orgId=Integer.parseInt(request.getParameter("orgId"));
            futureActivities = activityService.getOrgFutureActivities(orgId);
            Result result=new Result(1,futureActivities);
            hisoryActivities = activityService.getOrgHistoryActivities(orgId);
            return SUCCESS;
        }
     }

     public void setUserId(int userId)
     {
         this.userId=userId;
     }

     public int getUserId()
     {
         return this.userId;
     }

    public void setActivityService(ActivityService activityService)
    {
        this.activityService=activityService;
    }

    public ActivityService getActivityService()
    {
        return this.activityService;
    }

    public void setHisoryActivities(List<Activity> hisoryActivities)
    {
        this.hisoryActivities=hisoryActivities;
    }

    public List<Activity> getHisoryActivities()
    {
        return this.hisoryActivities;
    }

    public void setFutureActivities(List<Activity> futureActivities)
    {
        this.futureActivities=futureActivities;
    }

    public List<Activity> getFutureActivities()
    {
        return this.futureActivities;
    }

    public void setServletRequest(HttpServletRequest request)
    {
        this.request=request;
    }

}

